# Python 2.6.4
# Project Euler, Problem 45
# Copyright 2010 Talha Zaman

from time import clock

def T(n): return n*(n+1)/2
def P(n): return n*(3*n-1)/2
def H(n): return n*(2*n-1)

start = clock()
tn, pn, hn = 286, 165, 143
while not T(tn)==P(pn)==H(hn):
    while T(tn)<P(pn) or T(tn)<H(hn): tn += 1
    while P(pn)<T(tn): pn += 1
    while H(hn)<T(tn): hn += 1
stop = clock()
print tn, pn, hn, T(tn)

print "Time: ", stop-start
